﻿using aier.dataaccess.dapper;
using aier.dataaccess.model;
using aier.xrm.wcf;
using log4net;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Messages;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Dynamic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace aier.business.logic
{
    public class ScreenResultBll
    {
        public ILog log { get; set; }
        public ResResult resResult { get; set; }
        public CommonWcf commonWcf { get; set; }
        public ScreenResultDal screenResultDal { get; set; }

        /// <summary>
        /// 根据筛查ID查询筛查结果
        /// </summary>
        /// <param name="scid">筛查ID</param>
        /// <returns></returns>
        public IEnumerable<ScreenResultView> GetScreenResultsByScreenId(string scid)
        {
            return screenResultDal.GetScreenResultsByScreenId(scid);
        }


        /// <summary>
        /// 根据筛查ID,筛查客户ID查询完成的筛查项目
        /// 原程序 ScreeningServiceImpl-> selectScResultByScidAndCustomerid(String scid, String customerid) 
        /// </summary>
        /// <param name="scid">筛查ID</param>
        /// <param name="customerid">筛查客户ID</param>
        /// <returns></returns>
        public IEnumerable<string> GetSelectedByScreenIdAndCustomerId(Guid scid, Guid customerid)
        {
            return screenResultDal.GetSelectedByScreenIdAndCustomerId(scid, customerid)
                .GroupBy(t=>t)
                .Select<IGrouping<string,string>,string>(t=>t.Key);
        }

        /// <summary>
        /// 根据筛查ID,筛查客户ID查询筛查结果
        /// 原程序 ScreeningServiceImpl-> selectScResultByScidAndCustomerid(String scid, String customerid) 
        /// </summary>
        /// <param name="scid">筛查ID</param>
        /// <param name="customerid">筛查客户ID</param>
        /// <returns></returns>
        public IEnumerable<ScreenResultView> GetScreenResultsByScreenIdAndCustomerId(Guid scid, Guid customerid)
        {
            return screenResultDal.GetScreenResultsByScreenIdAndCustomerId(scid, customerid).OrderBy(t => t.new_categoryid);
        }

        public ScreenItemResultView GetScreenItemResultView(Guid scid, Guid customerid)
        {
            ScreenItemResultView screenItemResultView = new ScreenItemResultView();
            var screenResultView = this.GetScreenResultsByScreenIdAndCustomerId(scid, customerid);

            //右眼筛查结果
            string nakedEyeRight = GetResultItem(screenResultView, "LB0007", "XM0014", "NR0160");
            //左眼筛查结果
            string nakedEyeLeft = GetResultItem(screenResultView, "LB0007", "XM0014", "NR0161");
            //裸眼视力 右
            string visionRight = GetResultItem(screenResultView, "LB0007", "XM0014", "NR0023");
            //裸眼视力 左
            string visionLeft = GetResultItem(screenResultView, "LB0007", "XM0014", "NR0025");

            if (!string.IsNullOrWhiteSpace(nakedEyeRight) || !string.IsNullOrWhiteSpace(nakedEyeLeft) || !string.IsNullOrWhiteSpace(visionRight) || !string.IsNullOrWhiteSpace(visionLeft))
            {
                screenItemResultView.nakedEye = new ExpandoObject();
                screenItemResultView.nakedEye.nakedEyeRight = !string.IsNullOrWhiteSpace(nakedEyeRight) ? nakedEyeRight : string.Empty;
                screenItemResultView.nakedEye.nakedEyeLeft = !string.IsNullOrWhiteSpace(nakedEyeRight) ? nakedEyeLeft : string.Empty;
                screenItemResultView.nakedEye.visionRight = !string.IsNullOrWhiteSpace(visionRight) ? visionRight : string.Empty;
                screenItemResultView.nakedEye.visionLeft = !string.IsNullOrWhiteSpace(visionLeft) ? visionLeft : string.Empty;
            }

            //矫正视力 右
            string correctEyevisionRight = GetResultItem(screenResultView, "LB0007", "XM0010", "NR0024");
            //矫正视力 左
            string correctEyevisionLeft = GetResultItem(screenResultView, "LB0007", "XM0010", "NR0026");

            if(!string.IsNullOrWhiteSpace(correctEyevisionRight) || !string.IsNullOrWhiteSpace(correctEyevisionLeft))
            {
                screenItemResultView.correctEye = new ExpandoObject();
                screenItemResultView.correctEye.visionRight = !string.IsNullOrWhiteSpace(correctEyevisionRight) ? correctEyevisionRight : string.Empty;
                screenItemResultView.correctEye.visionLeft = !string.IsNullOrWhiteSpace(correctEyevisionLeft) ? correctEyevisionLeft : string.Empty;
            }

            //屈光检查
            string myopiaOrNot = GetResultItem(screenResultView, "LB0005", "XM0041", "NR0136");
            string myopiaYear = GetResultItem(screenResultView, "LB0005", "XM0041", "NR0138");
            string wearGlassesOrNot = GetResultItem(screenResultView, "LB0005", "XM0042", "NR0131");
            string optometryGlassesOrNot = GetResultItem(screenResultView, "LB0005", "XM0043", "NR0134");
          
            if (!string.IsNullOrWhiteSpace(myopiaOrNot)|| !string.IsNullOrWhiteSpace(wearGlassesOrNot)
                || !string.IsNullOrWhiteSpace(wearGlassesOrNot)|| !string.IsNullOrWhiteSpace(optometryGlassesOrNot)) {
                screenItemResultView.refractiveexamination = new ExpandoObject();
                screenItemResultView.refractiveexamination.myopiaYear = !string.IsNullOrWhiteSpace(myopiaYear) ? myopiaYear : string.Empty;
                screenItemResultView.refractiveexamination.myopiaOrNot = getScreenCallBackResult(myopiaOrNot);
                screenItemResultView.refractiveexamination.wearGlassesOrNot = getScreenCallBackResult(wearGlassesOrNot);
                screenItemResultView.refractiveexamination.optometryGlassesOrNot = getScreenCallBackResult(optometryGlassesOrNot);
            }
            

            //屈光度数检查
            string cylRight = GetResultItem(screenResultView, "LB0013", "XM0049", "NR0145");
            string cylLeft = GetResultItem(screenResultView, "LB0013", "XM0049", "NR0146");
            string pupilDistance = GetResultItem(screenResultView, "LB0013", "XM0052", "NR0151");
            string gazeMisalignment = GetResultItem(screenResultView, "LB0013", "XM0053", "NR0152");
            string pupilSizeRight = GetResultItem(screenResultView, "LB0013", "XM0051", "NR0149");
            string pupilSizeLeft = GetResultItem(screenResultView, "LB0013", "XM0051", "NR0150");
            string astigmatismAxisRight = GetResultItem(screenResultView, "LB0013", "XM0050", "NR0147");
            string astigmatismAxisLeft = GetResultItem(screenResultView, "LB0013", "XM0050", "NR0148");
            string sphericalDegreeRight = GetResultItem(screenResultView, "LB0013", "XM0047", "NR0143");
            string sphericalDegreeleft = GetResultItem(screenResultView, "LB0013", "XM0047", "NR0144");
            if (!string.IsNullOrWhiteSpace(cylRight) || !string.IsNullOrWhiteSpace(cylLeft)|| !string.IsNullOrWhiteSpace(pupilDistance)
                || !string.IsNullOrWhiteSpace(gazeMisalignment)|| !string.IsNullOrWhiteSpace(pupilSizeRight) || !string.IsNullOrWhiteSpace(pupilSizeLeft) 
                || !string.IsNullOrWhiteSpace(astigmatismAxisRight) || !string.IsNullOrWhiteSpace(astigmatismAxisLeft)
                || !string.IsNullOrWhiteSpace(sphericalDegreeRight) || !string.IsNullOrWhiteSpace(sphericalDegreeleft))
            {
                screenItemResultView.dioptertest = new ExpandoObject();
                screenItemResultView.dioptertest.cylRight = !string.IsNullOrWhiteSpace(cylRight) ? cylRight : string.Empty;
                screenItemResultView.dioptertest.cylLeft = !string.IsNullOrWhiteSpace(cylLeft) ? cylLeft : string.Empty;
                screenItemResultView.dioptertest.pupilDistance = !string.IsNullOrWhiteSpace(pupilDistance) ? pupilDistance : string.Empty;
                screenItemResultView.dioptertest.gazeMisalignment = !string.IsNullOrWhiteSpace(gazeMisalignment) ? gazeMisalignment : string.Empty;
                screenItemResultView.dioptertest.pupilSizeRight = !string.IsNullOrWhiteSpace(pupilSizeRight) ? pupilSizeRight : string.Empty;
                screenItemResultView.dioptertest.pupilSizeLeft = !string.IsNullOrWhiteSpace(pupilSizeLeft) ? pupilSizeLeft : string.Empty;
                screenItemResultView.dioptertest.astigmatismAxisRight = !string.IsNullOrWhiteSpace(astigmatismAxisRight) ? astigmatismAxisRight : string.Empty;
                screenItemResultView.dioptertest.astigmatismAxisLeft = !string.IsNullOrWhiteSpace(astigmatismAxisLeft) ? astigmatismAxisLeft : string.Empty;
                screenItemResultView.dioptertest.sphericalDegreeRight = !string.IsNullOrWhiteSpace(sphericalDegreeRight) ? sphericalDegreeRight : string.Empty;
                screenItemResultView.dioptertest.sphericalDegreeleft = !string.IsNullOrWhiteSpace(sphericalDegreeleft) ? sphericalDegreeleft : string.Empty;
            }
         

            //筛查判断
            List <dynamic> screenList = new List<dynamic>();
            screenItemResultView.scjudgeResult = screenList;

            string eyeSightValue = GetResultItem(screenResultView, "LB0012", "XM0062", "NR0172", "SC0000000013");
            if (!string.IsNullOrWhiteSpace(eyeSightValue))
            {
                dynamic objdy = new ExpandoObject();
                objdy.key = "双眼视力";
                objdy.name = eyeSightValue;
                screenList.Add(objdy);
            }

            string dicValue = GetResultItem(screenResultView, "LB0002", "XM0003", "NR0163", "SC0000000029");
            if (!string.IsNullOrWhiteSpace(dicValue))
            {
                dynamic objdy = new ExpandoObject();
                objdy.key = "翼状胬肉 (右眼)";
                objdy.name = dicValue;
                screenList.Add(objdy);
            }


            dicValue = string.Empty;
            dicValue = GetResultItem(screenResultView, "LB0002", "XM0003", "NR0164", "SC0000000029");
            if (!string.IsNullOrWhiteSpace(dicValue))
            {
                dynamic objdy = new ExpandoObject();
                objdy.key = "翼状胬肉 (左眼)";
                objdy.name = dicValue;
                screenList.Add(objdy);
            }

            dicValue = string.Empty;
            dicValue = GetResultItem(screenResultView, "LB0001", "XM0002", "NR0165", "SC0000000029");
            if (!string.IsNullOrWhiteSpace(dicValue))
            {
                dynamic objdy = new ExpandoObject();
                objdy.key = "白内障 (右眼)";
                objdy.name = dicValue;
                screenList.Add(objdy);
            }

  

            dicValue = string.Empty;
            dicValue = GetResultItem(screenResultView, "LB0001", "XM0002", "NR0166", "SC0000000029");
            if (!string.IsNullOrWhiteSpace(dicValue))
            {
                dynamic objdy = new ExpandoObject();
                objdy.key = "白内障 (左眼)";
                objdy.name = dicValue;
                screenList.Add(objdy);
            }


            dicValue = string.Empty;
            dicValue = GetResultItem(screenResultView, "LB0003", "XM0004", "NR0064", "SC0000000029");
            if (!string.IsNullOrWhiteSpace(dicValue))
            {
                dynamic objdy = new ExpandoObject();
                objdy.key = "泪道阻塞";
                objdy.name = dicValue;
                screenList.Add(objdy);
            }

            dicValue = string.Empty;
            dicValue = GetResultItem(screenResultView, "LB0010", "XM0029", "NR0043", "SC0000000029");
            if (!string.IsNullOrWhiteSpace(dicValue))
            {
                dynamic objdy = new ExpandoObject();
                objdy.key = "脸内翻 (倒睫)";
                objdy.name = dicValue;
                screenList.Add(objdy);
            }

            dicValue = string.Empty;
            dicValue = GetResultItem(screenResultView, "LB0002", "XM0003", "NR0155", "SC0000000029");
            if (!string.IsNullOrWhiteSpace(dicValue))
            {
                dynamic objdy = new ExpandoObject();
                objdy.key = "结膜炎";
                objdy.name = dicValue;
                screenList.Add(objdy);
            }

            dicValue = string.Empty;
            dicValue = GetResultItem(screenResultView, "LB0005", "XM0055", "NR0156", "SC0000000029");
            if (!string.IsNullOrWhiteSpace(dicValue))
            {
                dynamic objdy = new ExpandoObject();
                objdy.key = "屈光不正";
                objdy.name = dicValue;
                screenList.Add(objdy);
            }

            dicValue = string.Empty;
            dicValue = GetResultItem(screenResultView, "LB0010", "XM0029", "NR0157", "SC0000000029");
            if (!string.IsNullOrWhiteSpace(dicValue))
            {
                dynamic objdy = new ExpandoObject();
                objdy.key = "眼底疾病";
                objdy.name = dicValue;
                screenList.Add(objdy);
            }

            dicValue = string.Empty;
            dicValue = GetResultItem(screenResultView, "LB0012", "XM0056", "NR0158");
            if (!string.IsNullOrWhiteSpace(dicValue))
            {
                dynamic objdy = new ExpandoObject();
                objdy.key = "其他";
                objdy.name = dicValue;
                screenList.Add(objdy);
            }

            dicValue = string.Empty;
            dicValue = GetResultItem(screenResultView, "LB0012", "XM0046", "NR0142");
            if (!string.IsNullOrWhiteSpace(dicValue))
            {
                dynamic objdy = new ExpandoObject();
                objdy.key = "建议";
                objdy.name = dicValue;
                screenItemResultView.advise = objdy;
            }

            return screenItemResultView;
        }

        private string GetResultItem(IEnumerable<ScreenResultView> screenResultView, string new_categoryid,string itemid,string contentid)
        {
            return screenResultView.Where(item =>
                       (item.new_categoryid == new_categoryid && item.new_itemid == itemid && item.new_contentid == contentid)
                       && (!string.IsNullOrWhiteSpace(item.new_result))
                        ).Select(item => getScreenCallBackResult(item.new_result)).FirstOrDefault();
        }

        private string GetResultItem(IEnumerable<ScreenResultView> screenResultView, string new_categoryid, string itemid, string contentid,string result)
        {
            return screenResultView.Where(item =>
                       (item.new_categoryid == new_categoryid && item.new_itemid == itemid && item.new_contentid == contentid)
                       && (!string.IsNullOrWhiteSpace(item.new_result) && item.new_result!= result)
                        ).Select(item => getScreenCallBackResult(item.new_result)).FirstOrDefault();
        }

        private string getScreenCallBackResult(string item)
        {
            var result = string.Empty;
            switch (item)
            {
                case "SC0000000092":
                    return result = "已术";

                case "SC0000000093":
                    return result = "未术";

                case "SC0000000094":
                    return result = "未术";

                case "SC0000000095":
                    return result = "已术";

                case "SC0000000029":
                    return result = "无";

                case "SC0000000100":
                    return result = "初期";

                case "SC0000000101":
                    return result = "成熟";

                case "SC0000000050":
                    return result = "单侧";

                case "SC0000000020":
                    return result = "双侧";

                case "SC0000000116":
                    return result = "单侧复发";

                case "SC0000000117":
                    return result = "双侧复发";

                case "SC0000000002":
                    return result = "左";

                case "SC0000000001":
                    return result = "右";
                case "SC0000000008":
                    return result = "有";
                case "SC0000000070":
                    return result = "框架眼镜";
                case "SC0000000007":
                    return result = "隐形眼镜";
                case "SC0000000018":
                    return result = "是";
                case "SC0000000051":
                    return result = "否";
                case "SC0000000013":
                    return result = "正常";
                case "SC0000000005":
                    return result = "异常";
                default:
                    return item;
            }
        }

        /// <summary>
        /// 根据筛查ID,筛查客户ID查询筛查结果
        /// 原程序 ScreeningServiceImpl-> selectScResults(String scid, String customerid, List<String> contentids)
        /// </summary>
        /// <param name="scid">筛查ID</param>
        /// <param name="customerid">筛查客户ID</param>
        /// <param name="contentids">筛查内容ID</param>
        /// <returns></returns>
        public IEnumerable<ScreenResultView> GetScreenResultsByScreenIdAndCustomerIdAndContentIds(Guid scid, Guid customerid, List<string> contentids)
        {
            return screenResultDal.GetScreenResultsByScreenIdAndCustomerIdAndContentIds( scid,  customerid, contentids);
        }

        public IEnumerable<ScreenResultView> GetScreenResultsByScreenIdAndCustomerIdAndCategoryId(Guid scid, Guid customerid, string new_categoryid){
            return screenResultDal.GetScreenResultsByScreenIdAndCustomerIdAndCategoryId(scid, customerid, new_categoryid);
        }

        #region 更新
        /// <summary>
        /// 创建筛查结果
        /// 原程序 :ScResultServiceImpl-> save(TScResult entity)
        /// </summary>
        /// <param name="result">筛查结果</param>
        /// <returns></returns>
        public ResResult CreateScreenResult(ScreenResult result)
        {
            Guid entityId = Guid.Empty;
            Entity entity = result.AsCrmEntity();

            try
            {
                if (Guid.Empty.Equals(result.userid))
                {
                    entityId = commonWcf.CreateEntity(entity);
                }
                else
                {
                    entityId = commonWcf.CreateEntityProxy(result.userid, entity);
                }

                return resResult.SuccessResult(entityId);
            }
            catch (Exception ex)
            {
                log.Error("ScreenResultBll-> CreateScreenResult: " + ex.Message);
                return resResult.FailResult(ex.Message);
            }
        }

        /// <summary>
        /// 批量创建筛查结果 
        /// 原程序 :ScResultServiceImpl-> saveBatch(List<TScResult> scResults) 
        /// </summary>
        /// <param name="screenResults"></param>
        /// <returns></returns>
        public ResResult MutipleCreateResult(IEnumerable<ScreenResult> screenResults)
        {
            try
            {
                List<string> results = new List<string>();
                IEnumerable<Entity> entities = screenResults.AsCrmEntities();

                //记录批量操作所发时间
                Stopwatch watch = new Stopwatch();
                watch.Restart();
                string res = string.Empty;
                ExecuteMultipleResponse response = commonWcf.ExecultMutipleCreate(entities,out res);
                watch.Stop();
                double m = double.Parse(watch.ElapsedMilliseconds.ToString()) / 1000;

                log.Info("res:" + res);
                log.Info("ScreenResultBll-> MutipleCreateResult:批量操作所发时间秒 " + m.ToString());

                //提出创建成功后生成的ID
                foreach (ExecuteMultipleResponseItem responseItem in response.Responses)
                {
                    if (responseItem.Response != null)
                    {
                        var keyvaluepair = responseItem.Response.Results.FirstOrDefault();
                        results.Add(keyvaluepair.Value.ToString());
                    }
                }
                string ids = results != null ? string.Join("|", results.ToArray()) : string.Empty;
                log.Info("ids:" + ids);
                return resResult.SuccessResult(ids);
            }
            catch (Exception ex)
            {
                log.Error("ScreenResultBll-> MutipleCreateResult: " + ex.Message);
                return resResult.FailResult(ex.Message);
            }
        }

        /// <summary>
        /// 批量更新筛查结果 
        /// 原程序 :ScResultServiceImpl-> updateBatch(List<TScResult> scResults) 
        /// </summary>
        /// <param name="screenResults"></param>
        /// <returns></returns>
        public ResResult MutipleUpdateResult(IEnumerable<ScreenResult> screenResults)
        {
            try
            {
                List<string> results = null;
                IEnumerable<Entity> entities = screenResults.AsCrmEntities();

                //记录批量操作所发时间
                Stopwatch watch = new Stopwatch();
                watch.Restart();
                ExecuteMultipleResponse response = commonWcf.ExecultMutipleUpdate(entities);
                watch.Stop();
                double m = double.Parse(watch.ElapsedMilliseconds.ToString()) / 1000;
                log.Error("ScreenResultBll-> MutipleCreateResult:批量操作所发时间秒 " + m.ToString());

                //提出创建成功后生成的ID
                foreach (ExecuteMultipleResponseItem responseItem in response.Responses)
                {
                    if (responseItem.Response != null)
                    {
                        var keyvaluepair = responseItem.Response.Results.FirstOrDefault();
                        results.Add(keyvaluepair.Value.ToString());
                    }
                }

                string ids = results != null ? string.Join("|", results.ToArray()) : string.Empty;
                return resResult.SuccessResult(ids);
            }
            catch (Exception ex)
            {
                log.Error("ScreenResultBll-> MutipleUpdateResult: " + ex.Message);
                return resResult.FailResult(ex.Message);
            }
        }

        /// <summary>
        /// 批量更新筛查结果 
        /// 原程序 :ScResultServiceImpl-> updateBatch(List<TScResult> scResults) 
        /// </summary>
        /// <param name="screenResults"></param>
        /// <returns></returns>
        public ResResult MutipleUpdateResultParallel(IEnumerable<ScreenResult> screenResults)
        {
            try
            {
                //删除筛查结果
                if (screenResults != null && screenResults.Count() != 0)
                {
                    var deletesc_resultIds = screenResults.Where(item => item.new_sc_resultId != Guid.Empty)
                        .Select(item => item.new_sc_resultId.ToString()).ToArray();
                    //List<string> guids = new List<string>();
                    //foreach (ScreenResult item in screenResultRequest.screenResults) {
                    //    if (item.new_sc_resultId!=null&& item.new_sc_resultId!=Guid.Empty) {
                    //        guids.Add("'"+item.new_sc_resultId+"'");
                    //    }
                    //}
                    //string ids = string.Join(",",guids.ToArray());

                   DeleteScreenResultByGuid(deletesc_resultIds);
                }

                //批量创建结果
                //ScreenResultRequest screenResultRequest = new ScreenResultRequest();
                //screenResultRequest.screenResults = screenResults;
                resResult = MutipleCreateResult(screenResults);

                return resResult;
            }
            catch (Exception ex)
            {
                log.Error("ScreenResultBll-> MutipleUpdateResult: " + ex.Message);
                return resResult.FailResult(ex.Message);
            }
        }

        /// <summary>
        /// 批量创建筛查结果 
        /// 原程序 :ScResultServiceImpl-> updateBatch(List<TScResult> scResults) 
        /// </summary>
        /// <param name="screenResults"></param>
        /// <returns></returns>
        public ResResult MutipleParallelCreateResult(IEnumerable<ScreenResult> screenResults)
        {
            try
            {
                IEnumerable<Entity> entities = screenResults.AsCrmEntities();

                //记录批量操作所发时间
                Stopwatch watch = new Stopwatch();
                watch.Restart();
                Guid[] results = commonWcf.ExecultParallelMutipleCreate(entities);
                watch.Stop();
                double m = double.Parse(watch.ElapsedMilliseconds.ToString()) / 1000;
                log.Error("ScreenResultBll-> MutipleCreateResult:批量操作所发时间秒 " + m.ToString());

                string ids = results != null ? string.Join("|", results) : string.Empty;
                return resResult.SuccessResult(ids);
            }
            catch (Exception ex)
            {
                log.Error("ScreenResultBll-> MutipleCreateResult: " + ex.Message);
                return resResult.FailResult(ex.Message);
            }
        }

      
        /// <summary>
        /// 更新筛查结果
        /// 原程序 :ScResultServiceImpl-> update(TScResult entity)
        /// </summary>
        /// <param name="result">筛查结果对像</param>
        /// <returns></returns>
        public ResResult UpdateScreenResult(ScreenResult result)
        {
            try
            {
                Entity entity = result.AsCrmEntity();
                if (Guid.Empty.Equals(result.userid))
                {
                    commonWcf.UpdateEntityById(entity);
                }
                else
                {
                    commonWcf.UpdateEntityProxyById(result.userid, entity);
                }

                return resResult.SuccessResult();
            }
            catch (Exception ex)
            {
                log.Error("ScreenResultBll-> UpdateScreenResult: " + ex.Message);
                return resResult.FailResult(ex.Message);
            }
        }

        /// <summary>
        /// 删除筛查结果
        /// </summary>
        /// <param name="screenId">筛查ID</param>
        /// <param name="leadId">潜客ID</param>
        /// <returns></returns>
        public bool DeleteScreenResult(Guid leadId, Guid screenId)
        {
            return screenResultDal.DeleteScreenResultByScreenIdAndLeadId(screenId, leadId);
        }

        /// <summary>
        /// 根据categoryidid、itemid、contentid、customerid、scid删除筛查结果
        /// </summary>
        /// <param name="categoryidid">检查类别id</param>
        /// <param name="itemid">检查项目id</param>
        /// <param name="contentid">检查内容id</param>
        /// <param name="customerid">潜在顾客id</param>
        /// <param name="scid">活动id</param>
        /// <returns></returns>
        public bool DeleteScreenResultByContentId(string categoryidid,string itemid,string contentid,string customerid, string scid)
        {
            return screenResultDal.DeleteScreenResultByContentId(categoryidid, itemid, contentid, customerid, scid);
        }

        /// <summary>
        /// 根据id删除筛查结果
        /// </summary>
        /// <param name="leadId"></param>
        /// <param name="screenId"></param>
        /// <returns></returns>
        public bool DeleteScreenResultByGuid(string ids)
        {
            return screenResultDal.DeleteScreenResultByGuid(ids);
        }

        public bool DeleteScreenResultByGuid(string[] ids)
        {
            return screenResultDal.DeleteScreenResultByGuid(ids);
        }
        #endregion
    }
}
